package com.redrose.demo.fragment;

import android.view.View;
import android.view.ViewGroup;

import com.redrose.demo.bean.ListItem;
import com.redrose.demo.multiple.BaseMultipleViewHolder;

import java.util.List;

public class HomeAdapter extends HomeBaseAdapter{
    public HomeAdapter(List<ListItem> list) {
        super(list);
    }

    @Override
    protected BaseMultipleViewHolder<ListItem> getViewHolder(ViewGroup parent, int viewType) {
        BaseMultipleViewHolder<ListItem> holder = null;
        // TODO 构建数据源时，layoutRes需与viewType一一对应
        int layoutResId = getListItem(viewType);
        View viewByLayoutRes = getViewByLayoutRes(parent,layoutResId);
        switch (viewType) {
            case HomeFragment.ITEM_TITLE:
                holder = new HomeTitleHolder(parent, viewByLayoutRes);
                break;
            case HomeFragment.ITEM_INFO:
                holder = new HomeUserInfoHolder(parent, viewByLayoutRes);
                break;
            case HomeFragment.ITEM_IMAGE:
                holder = new HomeImageHolder(parent, viewByLayoutRes);
                break;
            default:
                break;
        }
        return holder;
    }
}
